import requestMeeting, { request } from '@/plugins/axios'
import {
	changeMixMembersEntity,
	FetchMixResponseEntity,
	PlanResponseEntity,
	PlanResponsePollEntity,
	StartParamsMixEntity,
} from './interface'
/**
 *
 * @param meeting_id 会议的meetingMoid
 * @param mix_id 会议主混音器，默认mix_id为1
 * @returns 获取会议混音当未开启混音时，不返回data
 */
export const fetchGetMixInfo = async (meeting_id: string, mix_id: number = 1) =>
	requestMeeting<FetchMixResponseEntity>({
		url: `/mcc/${meeting_id}/mixs/${mix_id}`,
		method: 'GET',
	}).then((res) => res)
/**
 *
 * @param meeting_id
 * @param members 混音成员
 * @param mix_id 会议主混音器，默认mix_id为1
 * @returns 添加混音成员
 */
export const fetchChangeMixMembers = async (
	meeting_id: string,
	members: Array<Partial<changeMixMembersEntity>>,
	mix_id = 1
) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/mixs/${mix_id}/members`,
		method: 'post',
		data: members,
	}).then((res) => res)
/**
 *
 * @param meeting_id
 * @param params
 * @returns 开启会议混音
 */
export const fetchStart = async (meeting_id: string, params: StartParamsMixEntity) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/mixs`,
		method: 'POST',
		data: params,
	}).then((res) => res)
/**
 *
 * @param meeting_id
 * @param mix_id 会议主混音器，默认mix_id为1
 * @returns 停止会议混音
 */
export const fetchStopMix = async (meeting_id: string, mix_id: number = 1, mix_mode: number) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/mixs/${mix_id}?mix_mode=${mix_mode}`,
		method: 'DELETE',
		data: {},
	}).then((res) => res.success)
/**
 *
 * @param meeting_id
 * @param mix_id 会议主混音器，默认mix_id为1
 * @returns 修改会议混音
 */
export const fetchChangeMixInfo = async (meeting_id: string, params: StartParamsMixEntity, mix_id: number = 1) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/mixs/${mix_id}`,
		method: 'PUT',
		data: params,
	}).then((res) => res)
/**
 *
 * @param meeting_id
 * @returns 终端哑音操作(支持批量)
 */
export const fetchUpdateMtMute = async (meeting_id: string, params: any) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/mts/mute`,
		method: 'PUT',
		data: params,
	}).then((res) => res.success)
/**
 *
 * @param meetingMoid
 * @returns 获取预案列表数据
 */
export const fetchGetMixPlanList = async (meetingMoid: string) =>
	requestMeeting<PlanResponseEntity>({
		url: `/meetings/${meetingMoid}/premixs?count=0`,
		method: 'GET',
	}).then((res) => res)
/**
 *
 * @param meeting_id
 * @returns 获取会议混音预案信息列表
 */
export const fetchGetMixPlanDetail = async (meeting_id: string, mix_id: string) =>
	request<PlanResponsePollEntity>({
		url: `/meetings/${meeting_id}/premixs/${mix_id}?type=1`,
		method: 'GET',
	}).then((res) => res)
/**
 *
 * @param meetingMoid 会议的meetingMoid
 * @param value 预案名称
 * @returns 删除预案
 */
export const fetchDeleteMixPlan = async (meetingMoid: string, value: string) =>
	requestMeeting({
		url: `/meetings/${meetingMoid}/premixs/${value}`,
		method: 'DELETE',
	}).then((res) => res)
/**
 *
 * @param meetingMoid 会议的meetingMoid
 * @param value 预案名称
 * @returns 新增预案
 */
export const fetchAddMixPlan = async (meetingMoid: string, plan_data: StartParamsMixEntity) =>
	requestMeeting({
		url: `/meetings/${meetingMoid}/premixs`,
		method: 'POST',
		data: JSON.stringify(plan_data),
	}).then((res) => res)
/**
 *
 * @param meetingMoid 会议的meetingMoid
 * @param value 预案名称
 * @returns 更新预案
 */
export const fetchUpdateMixPlan = async (meetingMoid: string, id: string, plan_data: StartParamsMixEntity) =>
	requestMeeting({
		url: `/meetings/${meetingMoid}/premixs/${id}`,
		method: 'POST',
		data: JSON.stringify(plan_data),
	}).then((res) => res)
